package com.zmn.oms.services.impl.conf.attachment;

import com.zmn.common.utils.date.DateUtil;
import com.zmn.oms.model.entity.conf.attachment.ConfOrderAttachmentCategory;
import com.zmn.oms.model.entity.conf.attachment.ConfOrderAttachmentCategoryQuery;
import com.zmn.oms.persistence.interfaces.conf.attachment.ConfOrderAttachmentCategoryDao;
import com.zmn.oms.services.interfaces.conf.attachment.ConfOrderAttachmentCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Slf4j
@Service
public class ConfOrderAttachmentCategoryServiceImpl  implements ConfOrderAttachmentCategoryService {

    @Autowired
    private ConfOrderAttachmentCategoryDao confOrderAttachmentCategoryDao;


    @Override
    public List<ConfOrderAttachmentCategory> listByQuery(ConfOrderAttachmentCategoryQuery query) {
        List<ConfOrderAttachmentCategory> confList = confOrderAttachmentCategoryDao.listByQuery(query);
        return confList;
    }

    @Override
    public List<ConfOrderAttachmentCategory> listByIds(List<Integer> idList) {
        List<ConfOrderAttachmentCategory> confList = confOrderAttachmentCategoryDao.listByIds(idList);
        return confList;
    }

    @Override
    public List<ConfOrderAttachmentCategory> listPageByQuery(ConfOrderAttachmentCategoryQuery query) {
        int count = confOrderAttachmentCategoryDao.countByQuery(query);
        query.setTotalCount(count);
        List<ConfOrderAttachmentCategory> confList = confOrderAttachmentCategoryDao.listPageByQuery(query);
        return confList;
    }

    @Override
    public int countByQuery(ConfOrderAttachmentCategoryQuery query) {
        return confOrderAttachmentCategoryDao.countByQuery(query);
    }

    @Override
    public ConfOrderAttachmentCategory findCategoryById(Integer id) {
        return confOrderAttachmentCategoryDao.selectByPrimaryKey(id);
    }

    @Override
    public void updateCategoryById(ConfOrderAttachmentCategory category) {
        Objects.requireNonNull(category.getCategId(), "ID不能为空");

        category.setUpdateTime(DateUtil.getNow());
        confOrderAttachmentCategoryDao.updateByPrimaryKeySelective(category);
    }

    @Override
    public Integer insertCategory(ConfOrderAttachmentCategory category) {
        category.setCreateTime(DateUtil.getNow());
        return confOrderAttachmentCategoryDao.insertSelective(category);
    }

    @Override
    public Integer batchModifyCategoryStatus(ConfOrderAttachmentCategory conf, List<String> categIdList){
        return confOrderAttachmentCategoryDao.batchModifyCategoryStatus(conf,categIdList);
    }

}
